#define   _CRT_SECURE_NO_WARNINGS 1
#include<stdlib.h>
#include <stdio.h>
#include<string.h>
struct stu
{
	char name[20];
	int age;
};
int cmp_stu_by_age(const void* e1, const void* e2)
{
	return ((struct stu*)e1)->age - ((struct stu*)e2)->age;
}
int cmp_stu_by_name(const void* e1, const void* e2)
{
	return strcmp(((struct stu*)e1)->name, ((struct stu*)e2)->name);
}
void test2()
{
	struct stu s[] = { {"zhangsan",20}, {"lise", 30}, {"wangwu", 18} };
	int sz = sizeof(s) / sizeof(s[0]);
	qsort(s, sz, sizeof(s[0]), cmp_stu_by_age);
}
void test3()
{
	struct stu s[] = { {"zhangsan",20}, {"lise", 30}, {"wangwu", 18} };
	int sz = sizeof(s) / sizeof(s[0]);
	qsort(s, sz, sizeof(s[0]), cmp_stu_by_name);
}
int main()
{
	test2();
	test3();

	return 0;
}